fun <T:AutoCloseable> useAndClose(input: T){
    input.close()
}

fun <T> useAndCloseAppend(input: T)
        where T:AutoCloseable,T:Appendable {
        input.append("there")
        input.close()
}
fun main() {
  val writer = java.io.StringWriter()
  writer.append("hello ") 
//   useAndClose(writer)
  useAndCloseAppend(writer)
  println(writer) 
}